<template>
	<view class="page group-apply">

		<nav-header title="群聊申请" :show-right="false">
		</nav-header>

		<!-- <view class="line"></view> -->
		<view class="hello">
			<view style="margin-bottom: 20rpx;">
				<text>附加信息(选填)</text>
			</view>
			<up-textarea v-model="content" placeholder="请输入内容"></up-textarea>
		</view>
		<view class="btn-group">
			<button class="btn btncolor" type="primary" @click="onAddGroup()">发送申请</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				content: null,
				groupId:null
			}
		},
		methods: {
			onAddGroup() {
				let userId = 0
				userId = this.userStore.userInfo.id
			
				let data = {
					groupId: this.groupId,
					userId: userId,
					context:this.content
				};
			
				console.log(data)
			
				this.$http({
					url: `/group/applyGroupById`,
					method: "POST",
					data: data
				}).then((group) => {
					uni.showToast({
						title: "已发起申请，等待群主或管理员通过",
						icon: "none"
					})
					setTimeout(() => {
						// 等一会跳转到上一页
						uni.navigateBack();
					}, 1000);
				})
			},
		},
		onLoad(options) {
			this.groupId=options.groupId
		}
	}
</script>

<style lang="scss" scoped>
	.group-apply {

		.hello {
			padding: 30rpx;

		}

		.line {
			margin: 30rpx;
			border-bottom: 1px solid #dddddd;
		}

		.btn-group {
			margin: 80rpx 30rpx;

			.btn {
				margin-top: 20rpx;
			}

			.btncolor {
				background-color: #048df5;
				color: #fff;
				font-size: 30rpx;
			}

		}
	}
</style>